var app = getApp();
Page({

  data: {
    data: '',
    money:'',
    password:'',
    mask: false,
    overly: false
  },
  // formid
  formSubmit: function (e) {
    var formId = e.detail.formId;
    var that = this;
    wx.getStorage({
      key: 'user',
      success: function (res) {
        wx.request({
          url: app.url.requestUrl + '/user/collect_formid',
          method: 'POST',
          data: {
            openid: res.data.openid,
            token: res.data.token,
            formid: formId
          },
          success: function (res) {
            if (res.data.code == 1) {
            }

          }
        })
      }
    })
  },
  close: function (e) {
    this.setData({
      mask: false,
      overly: false
    })
  },
  money:function(e){
    this.setData({
      money: e.detail.value
    })
  },
  password: function (e) {
    this.setData({
      password: e.detail.value
    })
  },
  //提现
  tx:function(e){
    var that = this;
    wx.getStorage({
      key: 'user',
      success: function (res) {
        wx.request({
          url: app.url.requestUrl + '/personal/tocash',
          method: 'POST',
          data: {
            openid: res.data.openid,
            token: res.data.token,
            money: that.data.money,
            password: that.data.password
          },
          success: function (res) {
            if(res.data.code==1){
              that.setData({
                mask: true,
                overly: true
              })
              wx.navigateTo({
                url: `../pages/my-money/my-money`,
              })
            }else{
              wx.showToast({
                title:res.data.msg,
                icon: 'none',
                duration: 2000

              });
            }
            
          }
        })
      },
    })
  },
  onLoad: function (options) {
    var that = this;
    wx.getStorage({
      key: 'user',
      success: function (res) {
        wx.request({
          url: app.url.requestUrl + '/personal/cash_data',
          method: 'POST',
          data: {
            openid: res.data.openid,
            token: res.data.token,
            order_id: options.id
          },
          success: function (res) {
            console.log(res.data)
            that.setData({
              data: res.data
            })
          }
        })
      },
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})